<template>
  <div class="coupon">
    <el-card>
      <h2>优惠券</h2>
      <el-table :data="coupons">
        <el-table-column prop="couponID" label="编号" />
        <el-table-column prop="couponvalue" label="面值" />
        <el-table-column prop="coupontime" label="有效期" />
        <el-table-column prop="couponstatus" label="状态" />
      </el-table>
      <el-alert v-if="msg" :title="msg" type="success" show-icon style="margin-top:10px;" />
    </el-card>
  </div>
</template>
<script>
import api from '@/api';
export default {
  data() {
    return {
      coupons: [],
      loading: false,
      msg: ''
    };
  },
  async created() {
    this.loading = true;
    try {
      this.coupons = await api.get('/coupon/list');
    } catch (e) {
      this.msg = '获取优惠券失败';
    }
    this.loading = false;
  }
};
</script>
<style scoped>
.coupon { max-width: 700px; margin: 40px auto; }
</style>
